package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainPaystatus;
import com.ktgj.train.service.ITrainPaystatusService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付状态Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/paystatus")
public class TrainPaystatusController extends BaseController
{
    @Autowired
    private ITrainPaystatusService trainPaystatusService;

    /**
     * 查询支付状态列表
     */
    @PreAuthorize(hasPermi = "train:paystatus:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainPaystatus trainPaystatus)
    {
        startPage();
        List<TrainPaystatus> list = trainPaystatusService.selectTrainPaystatusList(trainPaystatus);
        return getDataTable(list);
    }

    /**
     * 导出支付状态列表
     */
    @PreAuthorize(hasPermi = "train:paystatus:export")
    @Log(title = "支付状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainPaystatus trainPaystatus) throws IOException
    {
        List<TrainPaystatus> list = trainPaystatusService.selectTrainPaystatusList(trainPaystatus);
        ExcelUtil<TrainPaystatus> util = new ExcelUtil<TrainPaystatus>(TrainPaystatus.class);
        util.exportExcel(response, list, "支付状态数据");
    }

    /**
     * 获取支付状态详细信息
     */
    @PreAuthorize(hasPermi = "train:paystatus:query")
    @GetMapping(value = "/{paystatusid}")
    public AjaxResult getInfo(@PathVariable("paystatusid") Long paystatusid)
    {
        return AjaxResult.success(trainPaystatusService.selectTrainPaystatusById(paystatusid));
    }

    /**
     * 新增支付状态
     */
    @PreAuthorize(hasPermi = "train:paystatus:add")
    @Log(title = "支付状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainPaystatus trainPaystatus)
    {
        return toAjax(trainPaystatusService.insertTrainPaystatus(trainPaystatus));
    }

    /**
     * 修改支付状态
     */
    @PreAuthorize(hasPermi = "train:paystatus:edit")
    @Log(title = "支付状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainPaystatus trainPaystatus)
    {
        return toAjax(trainPaystatusService.updateTrainPaystatus(trainPaystatus));
    }

    /**
     * 删除支付状态
     */
    @PreAuthorize(hasPermi = "train:paystatus:remove")
    @Log(title = "支付状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paystatusids}")
    public AjaxResult remove(@PathVariable Long[] paystatusids)
    {
        return toAjax(trainPaystatusService.deleteTrainPaystatusByIds(paystatusids));
    }
}
